import ajax from '@/utils/request'
import { concatUrl } from '@/utils'

/**
 * 获取用户信息
 */
export function getUserInfo(data, fields: string | object = { fields: 'waitMoney,totalIncome,withdrawMoney,canDrawMoney,totalShareOrder,totalShareOrderCustomer' }, hideLoginModal) {
  return ajax({
    url: concatUrl('/v1/jihuasuan/jihuasuan/info', fields),
    data,
    method: 'GET',
    hideLoginModal
  })
}

/**
 * 获取活动商品列表
 */
export function getCheapGoodsList(data, fields: string | object = { fields: 'platformPrice,jihuasuanId,discount,mostReward,activityStatus,orderRecords,activityPrice,referUploadUrl,upload1Url,upload2Url,upload3Url,upload4Url,upload5Url,upload6Url,upload7Url,price,goods.annualCardItems,goods.platformPrice,goods.price,activityInfo.viewTimes,activityInfo.orderTimes,activityInfo.shareTimes,id,createdAt,updatedAt,title,keyword,wechatMiniUrl,blackBoxUrl,status,startAt,endAt,isLongTime,level,serviceChargeType,serviceCharge,index,uploadId1,uploadId2,uploadId3,uploadId4,shareBodyTitle,uploadId5,shareHeaderTitle,uploadId6,uploadId7,id,type,referId,referName,pCanReward,pRewardType,pReward,ppRewardType,ppReward,serviceCharge,referUploadId,index' }) {
  return ajax({
    url: concatUrl('/v1/jihuasuan/jihuasuan/goods-list', fields),
    data,
    method: 'GET'
  })
}

/**
 * 获取城市定位
 */
export function getAreaInfo(data, fields: string | object = { fields: '*' }) {
  return ajax({
    url: concatUrl('/v2/ad-area/get-area-info', fields),
    data,
    method: 'GET'
  })
}

/**
 * 获取下单门店
 */
export function getOrderDefaultStore(data, fields: string | object = { fields: '*' }) {
  return ajax({
    url: concatUrl('/v2/store/get-default-store', fields),
    data,
    method: 'GET'
  })
}

/**
 * 获取活动详情
*/
export function getCheapView(data, fields: string | object = { fields: 'rule,jihuasuanId,goods.discount,mostReward,activityStatus,orderRecords,goods.activityPrice,goods.referUploadUrl,upload1Url,upload2Url,upload3Url,upload4Url,upload5Url,upload6Url,upload7Url,price,goods.annualCardItems,goods.platformPrice,goods.price,activityInfo.viewTimes,activityInfo.orderTimes,activityInfo.shareTimes,id,createdAt,updatedAt,title,keyword,wechatMiniUrl,blackBoxUrl,status,startAt,endAt,isLongTime,level,serviceChargeType,serviceCharge,index,uploadId1,uploadId2,uploadId3,uploadId4,shareBodyTitle,uploadId5,shareHeaderTitle,uploadId6,uploadId7,goods.id,goods.type,goods.referId,goods.referName,goods.pCanReward,goods.pRewardType,goods.pReward,goods.ppRewardType,goods.ppReward,goods.serviceCharge,goods.referUploadId,goods.index' }) {
  return ajax({
    url: concatUrl('/v1/jihuasuan/jihuasuan/view', fields),
    data,
    method: 'GET'
  })
}

/**
 * 获取活动详情
*/
export function getAgreementLogCheck(data, fields: string | object = { fields: 'flag,id' }) {
  return ajax({
    url: concatUrl('/v1/agreement/agreement-log/check', fields),
    data,
    method: 'GET'
  })
}

// 协议记录
export function createAgreementLogCheck(data) {
  return ajax({
    url: concatUrl('/v1/agreement/agreement-log/create'),
    data,
    method: 'POST'
  })
}

/**
 * 获取活动详情
*/
export function getParamsByPId(data, fields: string | object = { fields: 'storeCode,activityId,directShareMobile,indirectShareMobile' }) {
  return ajax({
    url: concatUrl('/v1/jihuasuan/distribute-poster/get-params', fields),
    data,
    method: 'GET'
  })
}

/**
 * 获取一级分销人信息
*/
export function getpMobileInfo(data, fields: string | object = { fields: 'mobile,avatarUrl,userId,nickname' }) {
  return ajax({
    url: concatUrl('/v1/jihuasuan/jihuasuan/get-user-info', fields),
    data,
    method: 'GET'
  })
}

/**
 * 通过unionId比较小程序跟公众号用户信息是否对等
 */
export function compareUserByUnionId(data, fields: string | object = { fields: '' }) {
  return ajax({
    url: concatUrl('/v1/wechat-mini/compare-user-by-union-id', fields),
    data,
    method: 'GET'
  })
}
